package com.qinglei.recoup.system.controller;


import com.qinglei.recoup.common.domain.CommonRes;
import com.qinglei.recoup.common.exception.RedisConnectException;
import com.qinglei.recoup.common.utils.RecoupUtil;
import com.qinglei.recoup.system.pojo.RealTimeDataVO;
import com.qinglei.recoup.system.pojo.RealTimeDataVOV4;
import com.qinglei.recoup.system.service.RadarUserDataFourService;
import com.qinglei.recoup.system.service.RadarUserDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * @author dqh
 */
@RestController
@RequestMapping("/system/radar-user-data-four")
public class RadarUserDataFourController {

    @Autowired
    private RadarUserDataFourService radarUserDataFourService;


    @GetMapping("/getRealTimeData")
    public CommonRes<RealTimeDataVOV4> getRealTimeData(@NotNull(message = "{required}") Integer bedId,Integer second ) throws RedisConnectException {
        Integer tenantId = RecoupUtil.getCurrentUser().getTenantId();
        RealTimeDataVOV4 realTimeDataVOV4 = radarUserDataFourService.getRealTimeData(bedId,second,tenantId);
        if (realTimeDataVOV4 == null) {
            return CommonRes.failed("床位或者设备信息不存在");
        }
        return CommonRes.ok(realTimeDataVOV4);
    }

}
